﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ATM
{
    public class Account
    {
        AccountState curState,norState,goodState,warnState;
        double balance;
        public const double interest = 0.05;
        public const double lowLimit = 100;
        public const double highLimit = 10000;

        public Account()
        {
            norState = new NormalState(this);
            goodState = new GoodState(this);
            warnState = new WarningState(this);
            curState = norState;
        }

        public double Interest
        {
            get { return interest; }
        }

        public double Balance
        {
            get { return balance; }
            set { balance = value; }
        }

        public AccountState State
        {
            get { return curState; }
            set { curState = value; }
        }

        public void Deposit(double amount)
        {
            balance = curState.Deposit(amount);
        }

        public void Withdraw(double amount)
        {
            balance = curState.Withdraw(amount);
        }

        public void ChangeState()
        {
            if (balance <= lowLimit)
            {
                curState = warnState;
            }
            else if (balance > lowLimit && balance < highLimit)
            {
                curState = norState;
            }
            else if (balance > highLimit)
            {
                curState = goodState;
            }
        }
    }
}
